package ss.pku.jsa.type.io;

import java.io.BufferedReader;
import java.io.IOException;

public class FieldQSig extends QSig {
	String sig;
	String quals;

	public FieldQSig(String sig, String quals) {
		this.sig = sig;
		this.quals = quals;
	}

	public boolean isTracked() {
		return isTracked(this.quals);
	}

	public int hashCode() {
		return this.sig.hashCode();
	}

	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		FieldQSig other = (FieldQSig) obj;
		if (this.sig == null) {
			if (other.sig != null)
				return false;
		} else if (!this.sig.equals(other.sig))
			return false;
		return true;
	}

	public String toString() {
		return "field:\n" + this.sig + "\n" + this.quals + "\n";
	}

	public static QSig read(BufferedReader in) throws IOException {
		String sig = in.readLine();
		if (sig == null) {
			throw new IllegalArgumentException("No sig line");
		}
		String quals = in.readLine();
		return new FieldQSig(sig, quals);
	}
}
